feat(messaging): add messaging bridge pattern#377
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
Adds a new Messaging Bridge enterprise integration slice that bridges a MessageChannel<TInbound> into a MessageBus<TOutbound> with explicit translation + topic selection, alongside a source generator for bridge builder factories, plus docs/examples/tests/benchmarks and catalog updates to include the new pattern.
Changes:
- Introduces
MessagingBridge<TInbound,TOutbound>runtime API andMessagingBridgeGenerator([GenerateMessagingBridge]) with diagnostics. - Adds Partner Order bridge example (including DI registration), TinyBDD test coverage, and BenchmarkDotNet benchmarks for fluent vs generated parity.
- Updates pattern/generator/example docs, catalogs, README and benchmark coverage matrices to include “Messaging Bridge”.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Messaging/Bridges/MessagingBridgeTests.cs | Adds TinyBDD coverage for fluent bridge behavior (BridgeNext/BridgeAll + validation). |
| test/PatternKit.Generators.Tests/MessagingBridgeGeneratorTests.cs | Verifies generated factory output and generator diagnostics IDs. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Adds attribute coverage for GenerateMessagingBridgeAttribute. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates catalog tests to include the new pattern and count. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitBenchmarkCoverageTests.cs | Updates expected benchmark route-result totals to include the new pattern. |
| test/PatternKit.Examples.Tests/Messaging/PartnerOrderMessagingBridgeExampleTests.cs | Validates fluent/generated/DI-imported partner order bridge example. |
| src/PatternKit.Generators/Messaging/MessagingBridgeGenerator.cs | Adds incremental generator emitting a typed bridge builder factory + diagnostics. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new diagnostic IDs PKMBR001/PKMBR002. |
| src/PatternKit.Generators.Abstractions/Messaging/MessagingBridgeAttributes.cs | Adds [GenerateMessagingBridge] attribute definition. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Registers “Messaging Bridge” in the pattern catalog with docs/tests/example links. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds “Partner Order Messaging Bridge” example descriptor. |
| src/PatternKit.Examples/Messaging/PartnerOrderMessagingBridgeExample.cs | Implements fluent + generated bridge example, runner, DI wiring, and summary type. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Adds aggregate example registration for the messaging bridge demo. |
| src/PatternKit.Core/Messaging/Bridges/MessagingBridge.cs | Introduces the core MessagingBridge API + result type. |
| README.md | Updates pattern counts and benchmark table to include Messaging Bridge. |
| docs/patterns/toc.yml | Adds Messaging Bridge entry to the docs TOC (and Message Bus placement). |
| docs/patterns/messaging/messaging-bridge.md | Adds pattern documentation and fluent usage sample. |
| docs/guides/pattern-coverage.md | Adds Messaging Bridge row to the coverage guide table. |
| docs/guides/benchmarks.md | Adds Messaging Bridge benchmark rows. |
| docs/guides/benchmark-results.md | Adds Messaging Bridge benchmark rows + updates coverage matrix totals. |
| docs/generators/toc.yml | Adds Messaging Bridge generator doc to generators TOC. |
| docs/generators/messaging-bridge.md | Documents generator usage + diagnostics. |
| docs/generators/index.md | Adds generator overview entry for Messaging Bridge. |
| docs/examples/toc.yml | Adds Partner Order Messaging Bridge example entry. |
| docs/examples/partner-order-messaging-bridge.md | Adds example write-up and pointers to implementation/tests. |
| benchmarks/PatternKit.Benchmarks/Messaging/MessagingBridgeBenchmarks.cs | Adds construction/execution benchmarks for fluent vs generated bridge. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| using PatternKit.Messaging.Channels; | ||
|
|
||
| namespace PatternKit.Messaging.Bridges; | ||
|
|
||
| /// <summary> | ||
| /// Bridges messages from one channel topology into another bus while keeping translation explicit. | ||
| /// </summary> | ||
| public sealed class MessagingBridge<TInbound, TOutbound> | ||
| { | ||
| private readonly MessageChannel<TInbound> _source; | ||
| private readonly MessageBus<TOutbound> _target; | ||
| private readonly Func<Message<TInbound>, Message<TOutbound>> _translator; | ||
| private readonly Func<Message<TInbound>, string> _topicSelector; |
| var first = channels.CommerceEvents.TryReceive(); | ||
| var correlationId = first.Message?.Headers.CorrelationId; | ||
| if (first.Received && first.Message is not null) | ||
| channels.CommerceEvents.Send(first.Message); |
Test Results827 tests 827 ✅ 33s ⏱️ Results for commit a77126b. ♻️ This comment has been updated with latest results. |
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #377 +/- ##
==========================================
+ Coverage 89.60% 95.60% +5.99%
==========================================
Files 506 510 +4
Lines 41377 41628 +251
Branches 5972 6011 +39
==========================================
+ Hits 37075 39797 +2722
+ Misses 1959 1831 -128
+ Partials 2343 0 -2343
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fae0771 to
a77126b
Compare
Code Coverage |
Summary
[GenerateMessagingBridge]source-generated factory path and diagnosticsValidation
Benchmarks
Note:
dotnet test PatternKit.slnx --configuration Release --no-buildhit a runner timeout locally with stuck testhost processes, so the three test projects were rerun separately and passed.